Window Ports
Volume Number: 1
Issue Number: 5
Column Tag: PASCAL PROCEDURES
Windows provide a front end to ports
By Chris Derossi
In the last issue of MacTutor, we introduced briefly the concept of graph ports
and how they can make both programming and usage easier and more intuitive.
However, the way that we used the ports, the programmer had to keep track of
everything. It is fairly obvious that there will be several features that you, as a
programmer, would want to associate with ports frequently if not all the time. It is for
this reason that windows exist.
Windows provide a front end to ports, making them more easy to use and
providing you with several options and features. The Window Manager in the Macintosh
Toolbox takes care of the tedious tasks for you. For example, in our last program, we
had to do everything with the port, including erasing it to white and drawing the border
around the port. It is simple things like this, that you need for every port, that the
Window Manager handles.
In addition to taking care of the low level drawing, windows also provide you with
more complex options. I’m sure that you’ve seen the title bar on document windows,
and the scroll bar controls are standard, too. The Window Manager also sets the
window’s coordinate system to local coordinates, with the point (0,0) at the upper left
corner of the window. Also handled for you is the setting of the various regions. And,
unlike ports, windows can handle overlapping and res- toration of the window
contents.
Let’s back up a moment and take a look at the various different window kinds.
There are four standard windows in the Macintosh, and you may create your own.
The four standard windows are shown in figure #1. Each type has an associated
function on the Mac. Window type #0 is for documents, folders, and disks. Window
type #1 is the normal dialog and alert box window, with the shadow border.
Type #2 is like type #1, but without a border. Type #16 is usually found as the
window for a desk accessory. Types #0 and #16 have titles, while the other two do not.
Fig. 1
For each type of window, the Window Manager handles drawing of the border and
title bar. To do this, each window must have associated with it information about the
type of window, and the title for that window. In fact, the magic about windows is just
that: associating various things with a particular window.
Of course, the heart of the window is a GrafPort. Each window is its own port, and
is unrelated to other windows. The rules for windows are the same as those for ports
discussed last time. As you might have guessed, some of the other things associated with